# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=lib2geom
pkgver=1.4
pkgrel=0
pkgdesc="Easy to use 2D geometry library for c++"
url="https://gitlab.com/inkscape/lib2geom"
arch="all"
license="MPL-1.1 OR LGPL-2.1-only"
depends_dev="
	boost-dev
	cairo-dev
	double-conversion-dev
	gsl-dev
	"
makedepends="
	$depends_dev
	cmake
	cython
	gtk+3.0-dev
	ragel
	samurai
	"
checkdepends="gtest-dev"
subpackages="$pkgname-dev"
source="https://gitlab.com/inkscape/lib2geom/-/archive/$pkgver/lib2geom-$pkgver.tar.bz2"

# inkscape used to install the same shared library
replaces="inkscape"

# probably fpmath=sse related failures
case "$CARCH" in
x86) options="$options !check" ;;
esac

build() {
	CFLAGS="$CFLAGS -O2 -DNDEBUG -flto=auto" \
	CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-D2GEOM_BUILD_SHARED=ON \
		-D2GEOM_TESTING="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	# circle-test, line-test: failing on all
	# elliptical-arc-test, polynomial-test: failing on non-x86 64-bit
	ctest --test-dir build --output-on-failure \
		-E '(circle-test|line-test|elliptical-arc-test|polynomial-test)'
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
26a70d25a752d39c6d59c0f0cb8c0b2cdffe75de24db2079c2388bb19c1ec8caf0f8a189c8671c7e3a4d7e418993ac67fe15f6fd74a6e17f8d005b2e563f178d  lib2geom-1.4.tar.bz2
"
